package logic;

import java.util.Random;

/**
 * Class NemIDGenerator and its instance variables
 * 
 * @author Jakob
 * 
 *         This class contains the nemid method which generates the code which a
 *         user has to match to be authenticated, shown in the boolean method
 */
public class NemIDGenerator {

	private int nemid;

	/**
	 * Generates the nemid code/key by random within the numbers 1-10
	 */
	public void generateNemid() {
		Random randomNumbers = new Random();
		nemid = 1 + randomNumbers.nextInt(10);
	}

	/**
	 * 
	 * @return nemid
	 */
	public int getNemid() {
		generateNemid();
		return nemid;
	}

	/**
	 * authenticatesKey: matches the generated key with the key the user types
	 * in to a textField
	 * 
	 * @param key
	 * @return
	 */
	public boolean authenticateKey(int key) {
		boolean match = false;
		if (nemid == 1 && key == 7)
			match = true;
		else if (nemid == 2 && key == 4)
			match = true;
		else if (nemid == 3 && key == 9)
			match = true;
		else if (nemid == 4 && key == 10)
			match = true;
		else if (nemid == 5 && key == 8)
			match = true;
		else if (nemid == 6 && key == 2)
			match = true;
		else if (nemid == 7 && key == 5)
			match = true;
		else if (nemid == 8 && key == 1)
			match = true;
		else if (nemid == 9 && key == 6)
			match = true;
		else if (nemid == 10 && key == 3)
			match = true;
		return match;
	}

}
